<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>


<script>
    window.onload = function() {
        var xhr = null;
        if (window.XMLHttpRequest) {
            xhr = new XMLHttpRequest();
        } else {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xhr.open('get', './ajax.php?username=zhangsan');
        xhr.send(null);

        xhr.onreadyStatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    document.getElementsByTagName('span')[0].innerHTML = xhr.responText;


                }
            }
        }
    }
</script>

<body>

    <span></span>
</body>

</html>